import unittest
import requests
class TestAdd(unittest.TestCase):
    def test_001(self):
        resp=requests.post(url='http://ihrm2-test.itheima.net/api/sys/login',headers={"Content-Type":"application/json"},
                   json={"mobile":"13800000002","password":"123456"})
        self.assertEqual(200, resp.status_code)
        self.assertEqual(True, resp.json().get("success"))
        self.assertEqual(10000, resp.json().get("code"))
        self.assertEqual("操作成功！", resp.json().get("message"))
    def test_002(self):
        resp=requests.post(url='http://ihrm2-test.itheima.net/api/sys/login',headers={"Content-Type":"application/json"},
                   json={"mobile":"13800000002","password":"123456798"})
        self.assertEqual(200, resp.status_code)
        self.assertEqual(False, resp.json().get("success"))
        self.assertEqual(20001, resp.json().get("code"))
        self.assertEqual("用户名或密码错误", resp.json().get("message"))
    def test_003(self):
        resp=requests.post(url='http://ihrm2-test.itheima.net/api/sys/login',headers={"Content-Type":"application/json"},
                   json={"mobile":"13800000003","password":"123456"})
        self.assertEqual(200, resp.status_code)
        self.assertEqual(True, resp.json().get("success"))
        self.assertEqual(10000, resp.json().get("code"))
        self.assertEqual("操作成功！", resp.json().get("message"))
    def test_004(self):
        resp=requests.post(url='http://ihrm2-test.itheimalp[.net/api/sys/login',headers={"Content-Type":"application/json"},
                   json={"mobile":"null","password":"123456"})
        self.assertEqual(200, resp.status_code)
        self.assertEqual(False, resp.json().get("success"))
        self.assertEqual(20001, resp.json().get("code"))
        self.assertEqual("用户名或密码错误", resp.json().get("message"))